#include <Multiboot.h>
#include <MonitorDriver.h>
#include <Kernel.h>

Multiboot::Multiboot(MultibootHeader *h)
{
  header = h;
  
  symtab = NULL;
  strtab = NULL;

  // try and find the symtab/strtab
  if (isElf())
  {
    Elf32SectionHeader *shstrtab = (Elf32SectionHeader *)
                                 (header->addr+header->shndx*header->size);
    // try and loop through the section headers,
    // see if we can find the symbol table.
    for(u32int i = 0; i < header->num; i++)
    {
      Elf32SectionHeader *sh = (Elf32SectionHeader *)(header->addr + i*header->size);

      if (sh->type == SHT_SYMTAB)
      {
        symtab = sh;
      }
      else if (sh->type == SHT_STRTAB)
      { 
        char *c = (char *)shstrtab->addr + sh->name;
        if (!Kernel::strcmp(c, ".strtab"))
        {
          strtab = sh;
        }
      }
    }
  }
}


Multiboot::~Multiboot()
{
}


